{% extends 'base.html' %}
{% block title %}学生详情{% endblock %}
{% block content %}
<h2>学生：{{ student.name }} ({{ student.student_id }})</h2>
<p>班级：{{ student.class_name or '—' }}</p>
<div class="mb-3">
    <a href="{{ url_for('main.grade_add') }}" class="btn btn-primary">添加成绩</a>
</div>
<h3>成绩单</h3>
{% if student.grades %}
<table class="table table-bordered">
    <thead>
        <tr>
            <th>课程</th><th>分数</th><th>状态</th><th>操作</th>
        </tr>
    </thead>
    <tbody>
    {% for g in student.grades %}
        <tr>
            <td>{{ g.course.course_code }} - {{ g.course.name }}</td>
            <td>{{ g.score }}</td>
            <td>{{ g.grade_status or '' }}</td>
            <td>
                <a href="{{ url_for('main.grade_edit', id=g.id) }}" class="btn btn-sm btn-secondary">编辑</a>
                <form action="{{ url_for('main.grade_delete', id=g.id) }}" method="post" style="display:inline;">
                    {{ csrf_token() }}
                    <button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('确认删除该成绩？');">删除</button>
                </form>
            </td>
        </tr>
    {% endfor %}
    </tbody>
</table>
{% else %}
<p>该学生暂无成绩记录。</p>
{% endif %}
<a href="{{ url_for('main.student_list') }}" class="btn btn-secondary mt-3">返回列表</a>
{% endblock %}
